package org.micropayment.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;

/**
 *
 * @author jj
 */
@Entity
@Table(name = "MicropaymentUserAddress")
@NamedQueries({
    @NamedQuery(name = "MicropaymentUserAddress.findAll", query = "SELECT m FROM MicropaymentUserAddress m"),
    @NamedQuery(name = "MicropaymentUserAddress.findById", query = "SELECT m FROM MicropaymentUserAddress m WHERE m.id = :id")})
public class MicropaymentUserAddress implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "ID", nullable = false)
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Integer id;
    @JoinColumn(name = "micropaymentUserId", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private MicropaymentUser micropaymentUserId;
    @JoinColumn(name = "addressId", referencedColumnName = "id")
    @ManyToOne(optional = false)
    private Address addressId;

    public MicropaymentUserAddress() {
    }

    public MicropaymentUserAddress(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public MicropaymentUser getMicropaymentUserId() {
        return micropaymentUserId;
    }

    public void setMicropaymentUserId(MicropaymentUser micropaymentUserId) {
        this.micropaymentUserId = micropaymentUserId;
    }

    public Address getAddressId() {
        return addressId;
    }

    public void setAddressId(Address addressId) {
        this.addressId = addressId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MicropaymentUserAddress)) {
            return false;
        }
        MicropaymentUserAddress other = (MicropaymentUserAddress) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.micropayment.model.MicropaymentUserAddress[id=" + id + "]";
    }

}
